package org.SoccerTournament.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "Zones")
public class Zone implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private String name;
	
	private Long zoneId;
	
	private Set <Team>teams = new HashSet<Team>();
	
	
	public Zone(String name) {
		super();
		this.name = name;
	}

	public Zone() {
		super();
	}

	@Id
	@GeneratedValue
	@Column(name = "zoneId")
	public Long getZoneId() {
		return zoneId;
	}
	
	
	@Column(name = "name")
	public String getName() {
		return name;
	}
	
    
	public void addTeam(Team team){
		this.getTeams().add(team);
	}
	
	
	@OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
	@JoinColumn(name = "zoneId")
	public Set<Team> getTeams() {
		return teams;
	}
	
	public void setZoneId(Long zoneId) {
		this.zoneId = zoneId;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public void setTeams(Set<Team> teams) {
		this.teams = teams;
	}
}
